package ${package}.dao.demo;

import java.util.List;

import ${package}.entity.demo.User;
import org.springside.examples.miniservice.entity.user.User;
import org.springside.modules.orm.jpa.GenericDAO;

/**
 * User的DAO类.
 * 
 * 继承于泛型DAO基类GenericDAO,默认拥有增删改查的基本函数.
 * 用泛型定义管理的Entity类型为User,User的主键类型为Integer.
 * 
 * @author calvin
 */
public class UserDAO extends GenericDAO<User, Integer> {
	public User findByLoginName(Object loginName) {
		return findUniqueByProperty("loginName");
	}
	
	public List<User> findByName(Object name, int... rowStartIdxAndCount) {
		return findByProperty("name", name, rowStartIdxAndCount);
	}

	@SuppressWarnings("unchecked")
	public long countByAuth(String loginName, String password) {
		return (Long) findUniqueByNamedQuery("User.countByAuth", loginName, password);
		
	}
}